A rule in the book for this case is the Advantage rule.
With a character making little to no effort to defend themselves, you create a circumstance where the attacker has advantage.
Sometimes an ... attack roll ... is modified by special situations called advantage and disadvantage. Advantage reflects the positive circumstances surrounding a d20 roll, while disadvantage reflects the opposite. (Basic Rules, p. 4)
Advantage means two d20 rolls for the attacker; use the best score.
The DM can also decide that circumstances influence a roll in one
direction or the other and grant advantage or impose disadvantage as a
result. (Basic Rules, p. 57)
Simply advising the DM that you are doing nothing to defend yourself may cause the DM to give the attacker advantage. While there isn't an action called "anti dodge" not defending yourself is the opposite of the dodge1 action, which imposes disadvantage on the attack (mechanically). You can set up a signal with your DM -- "I am going to anti-dodge this round" -- to help speed up play. (Work with your DM to fit this to your table).
A simple way to create advantage for an attack upon you: Fall Down
If there is a melee attack being made upon you, falling down creates the prone condition. Your character being prone will provide the attacker with advantage on the attack (Appendix A; Conditions; Prone) within 5' of the prone character. (An exception to this is a lance attack which has disadvantage on attacks within 5')
The attacking enemy can still screw up on a given attack, in a general sense; rolling a 1 for a melee or ranged attack is always a miss2. Even in a case where the roll is made with advantage, which depending on AC will accrue a to-hit bonus of +4 or +5 (in terms of probability), the attacker can screw up and not make an effective hit.
A complete miss is less likely with advantage on an attack, but it is still possible.
Become paralyzed(the character who wants to get hit).
Paralyzed
• Attack rolls against the creature have advantage.
• Any attack that hits the creature is a critical hit if the attacker is
within 5 feet of the creature.
The character can apply some Crawler Mucus in order to get paralyzed.
Crawler Mucus (Contact).
A creature subjected to this poison must succeed on a DC 13 Constitution saving throw or be poisoned for 1 minute. The poisoned creature is paralyzed. The creature can repeat the saving throw at the end of each of its turns, ending the effect on itself on a success. (SRD V5.1 p. 204, DMG ref later)
Another solution is to not roll the dice
See Tom's answer for why rolling the dice need not be necessary. Discuss that with your DM.
1Dodge
When you take the Dodge action, you focus entirely on avoiding attacks. Until the start of your next turn, any attack roll made against you has disadvantage if you can see the attacker, and you make Dexterity saving throws with advantage. You lose this benefit if you are incapacitated (as explained in appendix A) or if your speed drops to 0. (Basic Rules, p. 72)
2Rolling 1 or 20
If the d20 roll for an attack is a 20, the attack hits regardless of any modifiers or the target’s AC. This is called a critical hit, which is explained later in this chapter. If the d20 roll for an attack is a 1, the attack misses regardless of any modifiers or the target’s AC. (Basic Rules, > p. 73)
About that shield(if being wielded)
There are not infinite spell slots. Based on the referenced GiTP thread, and presuming not-a-five-minute-adventuring day: if the character inviting this attack has a shield, but wants to be hit to exploit Armor of Agathys, then they are better off using their action that turn to doff (remove) the shield (it takes on action to do so) which removes its +2 from the armor class.
Doff. This is the time it takes to take off armor. If you have help,
reduce this time by half.
Category / Don / Doff Shield / 1 action / 1 action (Basic Rules p. 45)
The dexterity element of armor class isn't as easily discarded, but with the benefit from advantage being about +4 to +5, the advantage should at least take care of the dexterity bonus to armor class. (Depending upon the attackee's dexterity score).