As a fluid is heated the particles gain kinetic energy and spread further apart.
This causes fluid to become less dense and so will rise above any cooler fluid that hasn’t been heated.
As fluid cools down itl become more dense again, and will sink back down.