Robot .txt is a program file that allows crawlers to crawl on specific pages of the website.
keyword density is a completely different thing, it determines the amount of keyword on the page. Usually, it is ideal to have about 2-3% of keywords on a single page, more than that would be known as keyword stuffing which is not desirable.