DETROIT — General Motors said Monday that it earned $865 million in the first quarter, its first profit since 2007, after last year’s government-sponsored bankruptcy allowed the carmaker to wipe away many of its longstanding burdens.