Russia wouldn't have sold Alaska if the US didn't threaten to invade. After Crimean war, Russia was in no shape to defend Alaska from the US that's why they sold it cheap. Just like after Opium war China was in no shape to defend Outer Manchuria from Russia that's why they sold it cheap.
Its actually the British that threatened to invade Alaska through Canada. Russians now realised they could not hold Alaska for much longer not to mention the colony was losing its value.
Hence why they sold it to the Americans rather than giving it up to the British.