Why are tremors of an earthquake felt most on the upper floors of a building in comparison to lower floors? Does this have something to do with a third class lever?
First, your statement is not universally true. Motion of the bottom of a building can be greater or lesser in upper floors. It depends on the type of motion, how free the building is to move in other axes, where you are relative to the building center of mass, and whether the motion hits any resonant frequencies of the building.
If the motion excites a resonant frequency, then the motion will probably be larger as you go higher. Picture one of those cat toys that has a suction cup on one end, a flexible stick coming out of it, and a ball of soft material at the other. If you were to move the suction cup end a little sideways, you can get much larger movement of the ball if your motion is at the right frequency.
To show a reduced motion above the ground level, imagine a tall thin box sitting on a piece of paper on a table. If you move the paper back and forth quickly so as to move the bottom of the box while letting it pivot as it wants to, the middle of the box will move least. This is because the box is acting like a lever about its center of mass. On the "floor" that matches the center of mass, the motion is smaller than at the bottom. The motion then gets larger again going up from there.
Harmonic coupling with the building's natural vibration frequencies, dissipation of energy in a massive building, and the variety of vibration modes that can experience coupling could result in more or less displacement and more or less velocity at lower floors or upper floors. There's no universal relationship between either velocity or displacement between upper and lower floors.
Furthermore, earthquakes have two prominent types of waves, S waves and P waves. S waves move at a 45 degree angle to the propagation and will slowly fall behind P waves to the point that the earthquake actually separates into two phases. Having experienced this personally, it's actually easy to tell if you were at the epicenter or far away because the building motion changes and the quake has two distinct peaks. You don't need a seismometer for a large enough quake far enough away. The importance of the two wave types is that they can excite unique vibration modes, twisting vs bending, so there isn't even a universal answer for one building.
A tall building is the easiest way to visualize how the velocity and frequency at the ground and upper floors are not necessarily related.
The foundation is usually relatively fixed, though some designs attempt to de-couple ground movement from structure movement through the use of mechanical bearings of various sorts where the structure meets the foundation. At the fixed foundation, a tall building moves according to the earthquake. Heavy though the foundation may be, the earth is still heavier.
At the upper floors, if the building is in harmony with the motion, it will be as if pushing a light pole at its natural frequency. You will get it to break most likely and the motion at the top will be severe.
In tall buildings, typically this frequency is much larger than the earthquake frequency, so while some energy does accumulate, very little of it is conserved because of all the destructive interference and dissipation in the large number of structural connections. The dangerous buildings occur right around ten floors. Shorter than this, the building wants to vibrate faster than the quake. Taller than this, the building wants to vibrate more slowly than the quake. At extreme heights, energy dissipation becomes more pronounced as there is just too much mechanical loss through hysteresis for 2n or higher vibration modes to have much effect.
Here's really cool video of buildings that built up energy swaying after an earthquake. Note that the lateral movement at the top is large, but you can imagine that the velocities at the top related to the buildup are not extreme relative to the fixed foundations.