The density of a population of living organisms is usually measured in individuals on one square km. In here we have 50 earthworms on an area of 5 square meters, thus we have 10 earthworms on every square meter. In order to get to the result we need to see first how many square meters there are in one square km. One square km has one thousand meters of length and one thousand meters of width so:
1,000 x 1,000 = 1,000,000 km²
Since we established that we have 10 earthworms on every one square meter, we just need to multiply the number of square meters with the amount of earthworms on every square meter:
1,000,000 x 10 = 10,000,000
So we have a density of 10 million earthworms per square km.