It's marine plankton remains, mostly diatoms, to be precise.
And they don't "migrate" into the earth. They're deposited at the bottom of oceans and large lakes, and have sediments dumped on top of them over tens of millions of years. They're laid down and then stuff ends up on top of them.
For a long time people thought that oil was formed only by organic material including diatoms. Recent theories indicate that at least some is formed of inorganic material because of the high temperature and high pressure several miles below the surface.