It did not invade Crimea. Although to be fair this lie has been repeated many times by western media and politicians. A referendum was held which quite expectedly resulted in the Crimeans overwhelmingly siding with Russia
Russia has leases on naval bases in crimea until 2042, and an agreement dating back to the 1990's to have up to 25,000 troops in Crimea.
True, since 1997 Ukraine and Russia have had an agreement to have up to 25,000 Russian troops stationed in Crimea. However, this agreement also stated that the Russian troops ought to respect Ukrainian sovereignty, observe its laws and not
intervene in Ukrainian internal affairs. When crossing the Ukrainian border, Russian forces had to identify themselves and all Russian military movement (outside of their bases) had to be coordinated with Ukraine. Russia broke the terms of this treaty when it send in its 'little green men'.
Based on a
2013 poll, the 'expected result' of the referendum would be that circa 23% would vote for Crimea to join Russia. But, considering Russia's military occupation of the territory, 97% being in favor of union with Russia isn't all that unexpected.