“Attain” means “reach” and “obtain” means “get.”
You "attain" the summit of Mount Everest, you "obtain" a beautiful painting. “Attain” usually implies a required amount of hard work and difficulty; "Obtain" indicates you 'get' something but doesn't imply anything about difficulty or effort.
Also:
"Some things you obtain can also be attained. If you want to emphasize how hard you worked in college, you might say you attained your degree; but if you want to emphasize that you have a valid degree that qualifies you for a certain job, you might say you obtained it."