Yes, .gov and .edu backlinks improve your ranking. But taking links from these sites is not difficult.
1. Quality content to post in blog commenting.
2. Comment or link from relevant page or post.
3. Comment or post by your site authors or social profile with a strong influence.
.edu and .gov sites are high-authority sites.
It is not easy to get backlinks from these sites.
Join & comment on education & government forums,blogs.
Do submissions on education & government directories.