As above.
ESA, now only available to new applicants in its Contribution Based 'New Style' form is a UK state benefit for people who are unable to work due to a health condition or disability.
As the basis of claiming benefit while looking for work is that you're available for and ready to start work then it's absolutely normal to claim NS ESA while unemployed and unable to work due to health etc.
You will need medical evidence of incapacity for work. We used to call this a 'sick note' but in recent(ish) years it's been retitled a 'fit note'. Intention is to encourage medics to think beyond the binary can he work or not and consider whether work could be done with adequate support.
Assuming you meet the NI contribution condition it will be paid for 13weeks at £88/week based on the fit notes. During that period, called the Assessment Phase, you should be asked to complete a Work Capability Assessment form and, in most cases, attend a face to face or telephone assessment with a Health Professional.
There are three possible outcomes form that (a) you're actually fit for work, (b) you're not able to work but can get back into the workforce with help etc or (c) your unable to do work or work related activity at all. If the last of those applies you get a Support Addition added to the weekly payment.
Some people, with specific conditions such as Cancer treated with Chemo or Radiotherapy are 'passported' through the asssessment process.
In simple terms the assessment process is the same as that applied to means tested Universal Credit. If you cannot work due to ill health you may, depending on circumstances, get a top up through UC. A benefit checking tool such as Turn2Us or the Help to Claim Service on 0800 144 8 444 will help you check this out.